﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace exsportance.Silverlight.Common.Utils
{
    public static class ObjectUtils
    {
        /// <summary>
        /// Check sif a value is null or empty (if string = string.empty, if int = 0, etc.)
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static bool IsNullOrEmpty(this object value)
        {
            bool result = false;

            if (value == null)
                result = true;
            else
            {
                if (value is string)
                    result = String.IsNullOrEmpty(value as string);
                else
                    if (value is int)
                        result = (int)value == 0;
                    else
                        if (value is float)
                            result = (float)value == 0;
                        else
                            if (value is decimal)
                                result = (decimal)value == 0;
                            else
                                if (value is double)
                                    result = (double)value == 0;
                                else
                                    if (value is bool)
                                        result = (bool)value == false;
            }

            return result;
        }
    }
}
